package org.nowcoder.leetcode.bit;

/**
 * Title  : 342. Power of Four
 * Source : https://leetcode.cn/problems/power-of-four
 * Author : XrazYang
 * Date   : 2023-10-17
 */

public class LeetCode_342 {
    public boolean isPowerOfFour(int n) {
        if (n == 1) {
            return true;
        }
        if (n < 4) {
            return false;
        }
        while (n > 0) {
            if (n % 4 == 0) {
                n /= 4;
                if (n == 1) {
                    return true;
                }
            } else {
                break;
            }
        }
        return false;
    }
}
